#!/bin/sh

if [ "$1" = "-" ]; then
  cat
else
  git log --merges --pretty=format:'- %sXXX %b (AUTHOR)' "$@" |\
    perl -pe 's! from ([^/]+).+XXX (.+) \(AUTHOR\)!: \2 (\1)!g' |\
    perl -pe 's!Merge pull request #([[:digit:]]+)![#\1](https://github.com/PowerDNS/pdns/pull/\1)!g' |\
    perl -pe 's![#[[:digit:]]+]\(.+\): Backport #([[:digit:]]+)![#\1](https://github.com/PowerDNS/pdns/pull/\1)!g' |\
    perl -pe 's!\((rgacogne|habbie|ahupowerdns|pieterlexis|omoerbeek|aerique|chbruyand|fredmorcos)\)!!gi' |\
    perl -pe 's!\(mind04\)!(Kees Monshouwer)!g' |\
    perl -pe 's! $!!' |\
    grep -v dnsdist
fi
